package com.android.bookgarden.views;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.android.bookgarden.R;

import java.util.List;

/**
 * Create by zouqh
 * on 2018/12/4
 **/
public class InputPassWordLinearLayout extends LinearLayout {

    private TextView textView1,textView2,textView3,textView4,textView5,textView6;
    public InputPassWordLinearLayout(Context context) {
        super(context);
    }

    public InputPassWordLinearLayout(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        LayoutInflater.from(context).inflate(R.layout.input_password, this);
        textView1 = findViewById(R.id.text1);
        textView2 = findViewById(R.id.text2);
        textView3 = findViewById(R.id.text3);
        textView4 = findViewById(R.id.text4);
        textView5 = findViewById(R.id.text5);
        textView6 = findViewById(R.id.text6);
    }

    public void setPass(List<String> list){
        if (null==list){
            setTextNull();
        }else{
           switch (list.size()){
               case 1:
                   textView1.setText("*");
                   textView2.setText("");
                   textView3.setText("");
                   textView4.setText("");
                   textView5.setText("");
                   textView6.setText("");
                   break;
               case 2:
                   textView1.setText("*");
                   textView2.setText("*");
                   textView3.setText("");
                   textView4.setText("");
                   textView5.setText("");
                   textView6.setText("");
                   break;
               case 3:
                   textView1.setText("*");
                   textView2.setText("*");
                   textView3.setText("*");
                   textView4.setText("");
                   textView5.setText("");
                   textView6.setText("");
                   break;
               case 4:
                   textView1.setText("*");
                   textView2.setText("*");
                   textView3.setText("*");
                   textView4.setText("*");
                   textView5.setText("");
                   textView6.setText("");
                   break;
               case 5:
                   textView1.setText("*");
                   textView2.setText("*");
                   textView3.setText("*");
                   textView4.setText("*");
                   textView5.setText("*");
                   textView6.setText("");
                   break;
               case 6:
                   textView1.setText("*");
                   textView2.setText("*");
                   textView3.setText("*");
                   textView4.setText("*");
                   textView5.setText("*");
                   textView6.setText("*");
                   break;
           }
        }
    }

    private void setTextNull(){
        textView1.setText("");
        textView2.setText("");
        textView3.setText("");
        textView4.setText("");
        textView5.setText("");
        textView6.setText("");
    }
}
